package com.ugoodtech.mdcc.core.repository;

import com.ugoodtech.mdcc.core.domain.QuestionAnswerOption;
import java.util.List;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QueryDslPredicateExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;

public interface QuestionAnswerOptionRepository extends PagingAndSortingRepository<QuestionAnswerOption, Long>
        , QueryDslPredicateExecutor<QuestionAnswerOption> {

    @Query("from QuestionAnswerOption where deleted=false and enabled=true and name=:brandName and question_id=8")
    QuestionAnswerOption findByName(@Param("brandName") String brandName);

    @Query("from QuestionAnswerOption where deleted=false and enabled=true and  question_id=8")
    List<QuestionAnswerOption> findBrand();

    @Query("from QuestionAnswerOption where deleted=false and enabled=true and name in :brandNames and question_id=8")
    List<QuestionAnswerOption> findByNameList(@Param("brandNames") List<String> brandNames);

    @Query("from QuestionAnswerOption where deleted=false and enabled=true and name=:brandName")
    QuestionAnswerOption find_ByName(@Param("brandName") String name);

    @Query("from QuestionAnswerOption where deleted=false and enabled=true and name=:brandName and question_id=194")
    QuestionAnswerOption findComplaintBrandByName(@Param("brandName") String brandName);

    @Query("from QuestionAnswerOption where deleted=false and enabled=true and name in :brandNames and question_id=194")
    List<QuestionAnswerOption> findComplaintBrandByNameList(@Param("brandNames") List<String> brandNames);

    @Query("from QuestionAnswerOption where deleted=false and enabled=true and name=:name and question_id=:questionId")
    QuestionAnswerOption findByQuestionIdAndName(@Param("name") String name, @Param("questionId") Long questionId);

    @Query("from QuestionAnswerOption where deleted=false and enabled=true and id in "
        + ":answerId")
    List<QuestionAnswerOption> findByAnswerIdList(@Param("answerId") List<Long> answerId);


}
